<?php
    echo $this->Element('myfunction');
    

    echo "<div id='isi'>";
    if( !empty($jobs) )
    {
        echo "<table>"; 
        echo "<tr><th>Posted Date</th><th>Position</th><th>Career Level</th><th>Year Exp</th><th>Salary</th><th>Status</th><th>Action</th></tr>";
        foreach($jobs as $data)
        {
            echo "<tr>";
                echo "<td>".mydate($data['Job']['created'])."</td>";                     
                echo "<td>".$html->link($data['Job']['position'], array('controller' => 'jobs','action' => 'view','id' => $data['Job']['id']))."</td>";

                 
                if($data['Job']['entry']==1)
                echo "<td>Entry Level</td>";
                if($data['Job']['middle']==1)
                echo "<td>Middle</td>";
                if($data['Job']['senior']==1)
                echo "<td>senior</td>";
                if($data['Job']['top']==1)
                echo "<td>top</td>";

                echo "<td>".$data['Job']['experience']."</td>";
                if($data['Job']['salary']==0)
                { echo "<td>Negotiable</td>"; }
                if($data['Job']['salary']==1)
                { echo "<td>Rp 1 jt - 2 jt</td>"; }
                if($data['Job']['salary']==2)
                { echo "<td>Rp 2 jt - 3 jt</td>"; }
                if($data['Job']['salary']==3)
                { echo "<td>Rp 3 jt - 5 jt</td>"; }
                if($data['Job']['salary']==4)
                { echo "<td> > Rp 5 jt</td>"; }     
                

                if($data['Job']['end_date'] <= date("Y-m-d"))
                { echo "<td> Has Expired </td>"; }
                else
                { echo "<td> Still Posted </td>"; } 

                $applicant = $this->requestAction('applicants/new_applicant/'.$data['Job']['id']);
                if($applicant['new'])
                { echo "<td>".$html->link($applicant['total']."applicant(s)",array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id']))."  NEW </td>"; }
                else                     
                { echo "<td>".$html->link($applicant['total']."applicant(s)",array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id']))." </td>"; }
                    
            echo "</tr>";        
        }
        echo "</table>";
    }
    else
    { echo "There is no jobs in this category"; }
    echo "</div>";
    
    echo "<div id='wait' style='height:10px;visibility:hidden'>";
    if( !empty($wait) )
    {
        echo "<table>"; 
        echo "<tr><th>Posted Date</th><th>Position</th><th>Career Level</th><th>Year Exp</th><th>Salary</th><th>Status</th><th>Action</th></tr>";
        foreach($wait as $data)
        {
            echo "<tr>";
                echo "<td>".mydate($data['Job']['created'])."</td>";                     
                echo "<td>".$html->link($data['Job']['position'], array('controller' => 'jobs','action' => 'view','id' => $data['Job']['id']))."</td>";

                 
                if($data['Job']['entry']==1)
                echo "<td>Entry Level</td>";
                if($data['Job']['middle']==1)
                echo "<td>Middle</td>";
                if($data['Job']['senior']==1)
                echo "<td>senior</td>";
                if($data['Job']['top']==1)
                echo "<td>top</td>";

                echo "<td>".$data['Job']['experience']."</td>";
                if($data['Job']['salary']==0)
                { echo "<td>Negotiable</td>"; }
                if($data['Job']['salary']==1)
                { echo "<td>Rp 1 jt - 2 jt</td>"; }
                if($data['Job']['salary']==2)
                { echo "<td>Rp 2 jt - 3 jt</td>"; }
                if($data['Job']['salary']==3)
                { echo "<td>Rp 3 jt - 5 jt</td>"; }
                if($data['Job']['salary']==4)
                { echo "<td> > Rp 5 jt</td>"; }     
                
                if($data['Job']['slip']!='')
                { echo "<td> Waiting for activation </td>"; }
                else
                { echo "<td> Waiting for your payment </td>"; }
                
                echo "<td> ".$html->link('Edit',array('controller'=>'jobs','action'=>'edit','id'=>$data['Job']['id']) )." | ".$html->link('Payment',array('controller'=>'jobs','action'=>'payment','id'=>$data['Job']['id']) )." | ".$html->link('Cancel',array('controller'=>'jobs','action'=>'delete','id'=>$data['Job']['id']),array(),"Are you sure?" )." </td>"; 
                        
            echo "</tr>";        
        }
        echo "</table>";
    }
    else
    { echo "You have no job"; }

    echo "</div>";


                                                     
?>